package com.fare.taluo.core.domain.config.line;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Table;

import com.dayatang.domain.InstanceFactory;
import com.fare.taluo.base.ddd.domain.baseentity.BaseEntity;

@javax.persistence.Entity
@Table(name = "FDC_OCCUP_RATE")
@SuppressWarnings("serial")
public class OccupRateEntity extends BaseEntity{

	//航班公司
	@Column(name = "COMPANY_CODE")
	private String companyCode;
	
	//航线
	@Column(name = "LINE_CODE")
	private String lineCode;
	
	//航班
	@Column(name = "FLIGHTNO")
	private String flightInfo;
	
	@Column(name = "FLIGHT_DAY") //航班时间
	private Date flightDay;
	
	@Column(name = "PRICE")  //航班价格
	private Long price;
	
	@Column(name = "OCCUP_RATE")  //客座率
	private BigDecimal occupRate;
	
	@Column(name = "INCOME")//收益
	private BigDecimal income;
	
	@Column(name = "FROM_CITY")
	private String formCity; //起飞城市三字码
	
	@Column(name = "TO_CITY")
	private String toCity;//到达城市三字码
	
	
	public OccupRateEntity(){};
	
//    public OccupRateEntity(String companyCode, String lineCode,
//			String flightInfo, Date flightDay, Long price,
//			BigDecimal occupRate, BigDecimal income) {
//		super();
//		this.companyCode=companyCode;
//		this.lineCode=lineCode;
//		this.flightInfo=flightInfo;
//		this.flightDay=flightDay ;
//		this.price=price ;
//		this.occupRate=occupRate;
//		this.income=income;
//	}

   
    
    private static OccupRateEntityRepository occupRateEntityRepository;
	
	public static OccupRateEntityRepository getOccupRateEntityRepository() {
		if (occupRateEntityRepository == null) {
			occupRateEntityRepository = InstanceFactory.getInstance(OccupRateEntityRepository.class);
		}
		return occupRateEntityRepository;
	}
	
	//删除
	public void remove(){
		getOccupRateEntityRepository().remove(this);
	}
	
	//增加or更新
	public void saveOrUpdateOccupRateEntity(){
		getOccupRateEntityRepository().save(this);
	}
	
	public void saveOrUpdateOccupRateEntity(OccupRateEntity e){
		getOccupRateEntityRepository().save(e);
	}
	//查找
	public List<OccupRateEntity> findOccupRateEntityByCondition(String companyId,String lineCode,Date flightDay,int page,int pagesize){
		return getOccupRateEntityRepository().
				findOccupRateEntityByCondition(companyId,lineCode,flightDay,page,pagesize);
	}
	
	/**
	 * 航空公司、起发城市、终点城市、时间 查找
	 * @param companyId
	 * @param formCity
	 * @param toCity
	 * @param date
	 * @param page
	 * @param pagesize
	 * @return
	 */
	public List<OccupRateEntity> findOccupRateByCode(
			String companyId,String formCity,String toCity,Date date,int page,int pagesize){
		return getOccupRateEntityRepository().findOccupRateByCode(companyId, formCity, toCity, date, page, pagesize);
	}
	
	//分页总记录数
	public int getTotalOccupRateListByCodition(String companyId,String fromCity,String toCity, Date date){
		return getOccupRateEntityRepository().getTotalOccupRateListByCodition(companyId, fromCity, toCity ,date);
	}
	
	public List<OccupRateEntity> findOccupRateCondition2(String linkCode, String flightDay){
		return getOccupRateEntityRepository().findOccupRateCondition2(linkCode,flightDay);
	}
	public List<OccupRateEntity> findOccupRateEntity(String companyCode, String flightDay){
		return getOccupRateEntityRepository().findOccupRateEntity(companyCode,flightDay);
	}
	public  OccupRateEntity  findOccupRateEntityByCondition(String flightinfo, Date flightDay){
		List<OccupRateEntity> list = getOccupRateEntityRepository().findOccupRateEntityByCondition(flightinfo, flightDay);
		if(list!=null&&list.size()>0){
			return list.get(0);
		}else{
			return new OccupRateEntity();
		}
	} 
	public  List<OccupRateEntity>  findOccupRateEntityByCondition(String flightinfo, Date beginFlightDay,Date endFlightDay){
		return getOccupRateEntityRepository().findOccupRateEntityByCondition(flightinfo,beginFlightDay,endFlightDay);
	} 
//	public Long getId() {
//		return id;
//	}
//
//	public void setId(Long id) {
//		this.id = id;
//	}

	public Date getFlightDay() {
		return flightDay;
	}

	public void setFlightDay(Date flightDay) {
		this.flightDay = flightDay;
	}

	public Long getPrice() {
		return price;
	}

	public void setPrice(Long price) {
		this.price = price;
	}

	
	public BigDecimal getOccupRate() {
		return occupRate;
	}

	public void setOccupRate(BigDecimal occupRate) {
		this.occupRate = occupRate;
	}

	public BigDecimal getIncome() {
		return income;
	}

	public void setIncome(BigDecimal income) {
		this.income = income;
	}

	public String getCompanyCode() {
		return companyCode;
	}

	public void setCompanyCode(String companyCode) {
		this.companyCode = companyCode;
	}

	public String getLineCode() {
		return lineCode;
	}

	public void setLineCode(String lineCode) {
		this.lineCode = lineCode;
	}

	public String getFlightInfo() {
		return flightInfo;
	}

	public void setFlightInfo(String flightInfo) {
		this.flightInfo = flightInfo;
	}

	public String getFormCity() {
		return formCity;
	}

	public void setFormCity(String formCity) {
		this.formCity = formCity;
	}

	public String getToCity() {
		return toCity;
	}

	public void setToCity(String toCity) {
		this.toCity = toCity;
	}

}
